package aeolus.wind.spider.web.commons.vote;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import aeolus.wind.spider.biz.dataobject.Ability;
import aeolus.wind.spider.biz.dataobject.Vote;

public class VotedIdentity {

    private boolean        allVoted;
    private List<VoteItem> abilityVoteItemList;

    public VotedIdentity(String votedName, List<Ability> abilityList, Map<String, Vote> voteMap) {
        abilityVoteItemList = new ArrayList<VoteItem>();
        allVoted = true;
        for (Ability ab : abilityList) {
            VoteItem vi = new VoteItem(ab.getName(), ab.getDescription());
            Vote vote = voteMap.get(votedName + "@" + ab.getName());
            if (vote != null) {
                vi.setValue(vote.getValue());
            } else {
                allVoted = false;
            }
            abilityVoteItemList.add(vi);
        }
    }

    public List<VoteItem> getAbilityVoteItemList() {
        return abilityVoteItemList;
    }

    public boolean isAllVoted() {
        return allVoted;
    }

}
